package myky.com.doctorapp.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.facebook.drawee.view.SimpleDraweeView
import myky.com.doctorapp.R
import myky.com.doctorapp.api.Address
import myky.com.doctorapp.entity.MyConsultEntity

class MyConsultAdapter(myConsultEntitys: MutableList<MyConsultEntity.SpecialistConsultsEntity>) : BaseQuickAdapter<MyConsultEntity.SpecialistConsultsEntity, BaseViewHolder>(R.layout.activity_new_consult_list_adapter, myConsultEntitys) {
    override fun convert(helper: BaseViewHolder?, item: MyConsultEntity.SpecialistConsultsEntity?) {


        val simpleDraweeView = helper?.getView<SimpleDraweeView>(R.id.activity_new_consult_list_item_iv)


        val doctorBean = item?.doctor
        if (doctorBean != null) {
            simpleDraweeView?.setImageURI(Address.IMAGE + doctorBean.headPhoto)

            helper?.setText(R.id.activity_new_consult_list_item_name, doctorBean.realname)
            helper?.setText(R.id.activity_new_consult_list_item_department, doctorBean.doctoradministration + "\u3000 " + doctorBean.departmentname)
        }
        helper?.setText(R.id.activity_new_consult_list_item_tv, item?.content)
        helper?.setText(R.id.activity_new_consult_list_item_date, item?.createtime)
        val state = item?.consultStatus
        if (state == 2) {
            helper?.setText(R.id.activity_new_consult_list_item_state, "已回复")

            helper?.setTextColor(R.id.activity_new_consult_list_item_state, mContext.resources.getColor(R.color.theme_app))
        } else if (state == 1 || state == 0) {
            helper?.setText(R.id.activity_new_consult_list_item_state, "待回复")
            helper?.setTextColor(R.id.activity_new_consult_list_item_state, mContext.resources.getColor(R.color.yellow_f5a628))
        } else if (state == 3) {
            helper?.setText(R.id.activity_new_consult_list_item_state, "已取消")
            helper?.setTextColor(R.id.activity_new_consult_list_item_state, mContext.resources.getColor(R.color.gray_999999))
        }
        when (doctorBean!!.type) {
            0 -> {
                helper?.setVisible(R.id.act_new_team_consult_icon, false)
                helper?.setVisible(R.id.activity_new_consult_list_item_teamname, false)
            }
            1 -> {
                helper?.setVisible(R.id.act_new_team_consult_icon, true)
                helper?.setVisible(R.id.activity_new_consult_list_item_teamname, true)
                helper?.setText(R.id.activity_new_consult_list_item_teamname, item.allname)
            }
        }


        helper?.addOnClickListener(R.id.rootLayout)


    }
}